<template>
	<!-- 邮寄订单 -->
	<view class="mailorder_wp">
		<view class="m_nav">
			<view :class="{'m_nav_active':active==0}" @click="navTap(0)">待付款</view>
			<view :class="{'m_nav_active':active==1}" @click="navTap(1)">待发货</view>
			<view :class="{'m_nav_active':active==2}" @click="navTap(2)">待收货</view>
			<view :class="{'m_nav_active':active==3}" @click="navTap(3)">已完成</view>
			<view :class="{'m_nav_active':active==4}" @click="navTap(4)">售后</view>
		</view>
		<view class="m_list">
			<view class="m_item" v-for="item in list" :key="item.id"  @click="$navTo('../business/mailorderdetails?id='+item.id)">
				<view class="m_item_head">
					<view>订单号：{{item.ordersn}}</view>
					<view>{{item.statusName}}</view>
				</view>
				<view class="m_item_body" v-for="iitem in item.goodsList" :key="iitem.id">
					<image :src="iitem.thumb" ></image>
					<view class="m_item_name">
						<view class="m_item_title">{{iitem.goodstitle}}</view>
						<view class="m_item_price"><text>{{iitem.realprice}}米券</text><text>×{{iitem.total}}</text></view>
					</view>
				</view>
				<view class="m_item_money">
					<text>总价</text><text>{{item.price}}</text><text>米券</text>
				</view>
			</view>
		</view>
		<view class="loading_message">
			<image v-if="isloading" src="/static/business/loading.gif" ></image>
			<text v-if="isempty">到底了~</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				active: 0,
				
				list:[],
				page:0,
				
				stoploading:false,
				isloading:false,
				isempty:false,
			}
		},
		onReachBottom() {
			this.getList();
		},
		onLoad(option) {
			this.active=option.status?option.status:this.active;
			this.getList();
		},
		methods: {
			getList(){
				this.page+=1;
				if(this.stoploading) return ;
				this.stoploading=true;
				this.isloading=true;
				this.$axios('order/sorder','POST','supplier',{page:this.page,status:this.active}).then(res=>{
					this.isloading=false;
					if(res.data.code==200){
						let length=res.data.data.list.length;
						this.list=this.list.concat(res.data.data.list);
						this.isempty=length<10?true:false;
						this.stoploading=length<10?true:false;
					}
				})
			},
			navTap(e) {
				if (this.active == e) return;
				this.active = e;
				this.page=0;
				this.list=[];
				this.stoploading=false;
				this.isempty=false;
				this.getList();
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f2f2f2;
		color: $font-color-dark;
		padding-bottom: 130upx;
	}

	.m_nav {
		background-color: #fff;
		display: flex;
		align-items: center;
		line-height: 100upx;
		position: fixed;
		width: 100%;
		z-index: 100;
	}

	.m_nav view {
		flex: 1;
		text-align: center;
		font-size: $font-base;
		position: relative;
	}

	.m_nav_active:after {
		content: '';
		border-bottom: 3px $base-color solid;
		position: absolute;
		left: 50%;
		transform: translateX(-50%);
		bottom: 20upx;
		width: 40upx;
	}

	.m_list {
		padding-top: 100upx;
		overflow: hidden;
	}

	.m_item {
		background-color: #fff;
		border-radius: 10upx;
		margin: 20upx 20upx 0;
		padding: 20upx;

	}

	.m_item_head,
	.m_item_body,
	.m_item_price {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.m_item_head view:nth-of-type(2) {
		color: $base-color;
	}

	.m_item_body {
		border-bottom: 1px hsl(0, 0%, 87%) solid;
		align-items: flex-start;
		padding: 20upx 0;
	}

	.m_item_body image {
		border-radius: 10upx;
		width: 140upx;
		height: 140upx;
	}

	.m_item_name {
		flex: 1;
		padding-left: 20upx;
		line-height: 35upx;
	}

	.m_item_title {
		height: 68upx;
		overflow: hidden;
	}

	.m_item_price {
		padding-top: 35upx;
	}

	.m_item_price text:nth-of-type(2) {
		font-size: 34upx;
	}

	.m_item_money {
		padding: 30upx 0;
		text-align: right;
	}

	.m_item_money text:nth-of-type(2) {
		margin-left: 10upx;
		color: $base-color;
	}

	.m_item_money text:nth-of-type(3) {
		color: $base-color;
		font-size: 20upx;
	}
	.loading_message{
		color: #0062CC;
		padding: 20upx;
		text-align: center;
	}
	.loading_message image{
		height: 50upx;
		width: 50upx;
	}
</style>
